<html>
<head>

<title>Groovy Goodness: Resolve Module Location with Grape</title>

<script language="javascript" src="scripts/shCore.js"></script> 
<script language="javascript" src="scripts/shLegacy.js"></script> 
<script language="javascript" src="scripts/shBrushJava.js"></script> 
<script language="javascript" src="scripts/shBrushXml.js"></script> 
<script language="javascript" src="scripts/shBrushJScript.js"></script> 
<script language="javascript" src="scripts/shBrushGroovy.js"></script> 
<script language="javascript" src="scripts/shBrushPlain.js"></script> 
<script language="javascript" src="scripts/shBrushBash.js"></script> 
 
<link href="styles/reset.css" rel="stylesheet" type="text/css" />
<link href="styles/shCore.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="styles/shThemeRDark.css"/>
<link href="styles/blog.css" rel="stylesheet" type="text/css" />

</head>
<body>

<a href="index.html">Back to index</a>

<h3 class="post-title">Groovy Goodness: Resolve Module Location with Grape</h3>

<div class="post">
<p><a href="http://mrhaki.blogspot.com/2009/09/groovy-goodness-grab-that-dependency.html">Grape in Groovy</a> is a great way to define dependencies in our scripts and let Groovy download them automatically for us. We also can use the command-line tool <code>grape</code> to resolve the location of modules on our system. We use the <code>resolve</code> command to get the absolute path to our dependency, but we can even pass extra arguments like <code>-shell</code> and <code>-dos</code> and we get the location as a <code>CLASSPATH</code> environment variable. If we use <code>-ant</code> we can use the output in a ANT build file. Or <code>-ivy</code> to get the information in Ivy XML format.</p>
<pre class="brush:plain">
$ grape resolve commons-lang commons-lang 2.5
/Users/mrhaki/.groovy/grapes/commons-lang/commons-lang/jars/commons-lang-2.5.jar

$ grape resolve -dos commons-lang commons-lang 2.5
set CLASSPATH=/Users/mrhaki/.groovy/grapes/commons-lang/commons-lang/jars/commons-lang-2.5.jar

$ grape resolve -shell commons-lang commons-lang 2.5
export CLASSPATH=/Users/mrhaki/.groovy/grapes/commons-lang/commons-lang/jars/commons-lang-2.5.jar

$ grape resolve -ant commons-lang commons-lang 2.5
&lt;pathelement location="/Users/mrhaki/.groovy/grapes/commons-lang/commons-lang/jars/commons-lang-2.5.jar"&gt;

$ grape resolve -ivy commons-lang commons-lang 2.5
&lt;dependency org="commons-lang" name="commons-lang" revision="2.4"&gt;
</pre
</div>

<script language="javascript"> 
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
SyntaxHighlighter.defaults['first-line'] = 0;
SyntaxHighlighter.defaults['auto-links'] = false;
SyntaxHighlighter.all();
dp.SyntaxHighlighter.HighlightAll('code');
</script>

</body>
</html>